// 封装所有文章的请求
import request from '@/utils/request.js'

// 获取文章列表
export const getArticleList = params => {
  return request({
    method: 'GET',
    url: '/v1_1/articles',
    params
  })
}

// 获取新闻文章详情
export const getArticleInfo = id => {
  return request({
    method: 'GET',
    url: '/v1_0/articles/' + id
  })
}

// 收藏文章请求
export const addArticleCollected = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target: id
    }
  })
}

// 取消收藏文章请求
export const deleteArticleCollected = id => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/collections/' + id
  })
}

// 取消文章点赞
export const deleteArticleLike = id => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/likings/' + id
  })
}

// 文章点赞
export const addArticleLike = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}
